
fdef = open('./QSubWidgets.py', "w+")

import makeui



fdef.write('''
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
''')

filters = ['QAccessibleWidget', 'QColormap', 'QGraphicsItemAnimation', 'QTileRules']

for widget in makeui.controls:
    # 判断是否为QT原生Widget
    # 通过首字母进行判断
    if widget[0:1] != 'Q':
        continue

    # 生成新的定义
    class_def = '''
class C'''+widget + '''('''+widget+'''):
    def __init__(self):
        super().__init__()
    def mousePressEvent(self, event):
        print("'''+widget+''' mouse pressed")
        super().mousePressEvent(event)
    '''
    fdef.write(class_def+"\n")

fdef.close()